<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>props基础使用</title>
</head>

<body>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://cdn.staticfile.org/typescript/4.9.4/typescript.js"></script>
    <div id="Application">
        <child text="Hello World" :message="messages"></child>
    </div>
    <script lang="ts">
        const App = Vue.createApp({
            setup() {
                const messages = Vue.ref(233)
                return {
                    messages
                }
            },
        });

        //子组件
        const childBlock = {
            props: {
                text: {
                    type: String,
                    default: ""
                },
                message: Number
            },
            setup(props) {
                const { text } = Vue.toRefs(props)

                let formatText = Vue.ref("Hi~")
                formatText.value = formatText.value + text.value
                return {
                    text,
                    formatText
                }

            },

            template: '<!-- hello world -->{{text}}<br /><!-- Hi,hello world-->{{formatText}}<br /><!-- 233 -->{{message}}'

        }
        App.component("child", childBlock);

        //挂载
        App.mount("#Application");
    </script>
</body>

</html>